package com.ming.day250808;

public class c_arrayram {
    public static void main(String[] args) {
        //数组合并
        int[] arr1 = {1,2,3};
        int[] arr2 = {4,5,6};

        //创建新数组,长度为arr1的长度+arr2的长度
        int[] arr3 = new int[arr1.length+arr2.length];

        for (int i = 0; i < arr1.length; i++) {
            arr3[i] = arr1[i];
        }

        /*
           i = 0 -> arr3[0+3] = arr2[0]
           i = 1 -> arr3[1+3] = arr2[1]
           i = 2 -> arr3[2+3] = arr2[2]
         */
        for (int i = 0; i < arr2.length; i++) {
            arr3[i+arr1.length] = arr2[i];
        }

        //遍历arr3
        for (int i = 0; i < arr3.length; i++) {
            System.out.println(arr3[i]);
        }

        ////数组扩容
        //int[] arr1 = {1,2,3};
        //int[] arr2 = new int[5];
        ////将arr1的元素 放到arr2中
        //for (int i = 0; i < arr1.length; i++) {
        //    arr2[i] = arr1[i];
        //}
        //
        ////将arr2的地址值给arr1
        //arr1 = arr2;
        //
        //for (int i = 0; i < arr1.length; i++) {
        //    System.out.println(arr1[i]);
        //}
    }
}
